<%-- 
    Document   : consulta
    Created on : 27/04/2012, 10:45:38
    Author     : Filipe
--%>

<%@page import="br.ufjf.posjava.cm.util.TrataDatas"%>
<%@page import="org.apache.naming.java.javaURLContextFactory"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@taglib prefix="f" uri="http://java.sun.com/jsp/jstl/fmt" %>

<script language="javascript" src="funcoes.js"></script>
<div  style="background-color: #FFFFFF; padding: 50px; margin-top: 40px; ">
    <form action="Controller?action=RealizarConsulta" method="POST">
        <input type="hidden" name="idAgenda" value="${requestScope.ag.idAgenda}" />
        <input type="hidden" name="idProfissional" value="${sessionScope.profissional.idProfissional}" />
        
        <fieldset>
            <legend>
                Consulta
            </legend>        
            <table width="364"> 
                <tr> 
                    <td width="73">Data</td>                    
                    <td><input type="text" name="cpData" value="${requestScope.dataFormatada}"/></td>
                </tr>
                <tr> 
                    <td>Paciente</td>
                    <c:forEach items="${requestScope.ListaPaciente}" var="p">
                        <c:if test="${p.idPaciente == requestScope.ag.paciente.idPaciente}">                            
                            <td><input type="text" name="cpPaciente" value="${p.nome}"/></td>                
                            </c:if>
                    </c:forEach>
                </tr>
                <tr> 
                    <td>Serviço</td>
                    <td width="275">
                        <select name="cpServico" id="cpServico">
                            <option value="-1" style="background: #eeeeee">Escolha um serviço...</option>
                            <c:forEach items="${requestScope.ListaServico}" var="serv">
                                <option value="${serv.idServico}">${serv.descricao}</option>                            
                            </c:forEach>
                        </select>
                    </td>
                </tr>
                <tr> 
                    <td>Valor</td>
                    <td>
                        <div  id="dvValor" ></div>
                        <!--                            <input type="text" name="cpValor"  id="cpValor" value=""/>-->
                    </td>
                </tr> 
                <tr> 
                    <td>Obs.:</td>
                    <td><label>
                            <textarea name="cpObs" id="cpObs" cols="35" rows="6"></textarea>
                        </label></td>
                </tr> 

            </table>
        </fieldset>
        <tr>
            <td colspan="2">
                <input type="submit" name="btn" value="Confirmar" />
                <input type="submit" name="btn" value="Cancelar" />
            </td>
        </tr>
    </form>    
    <br /><br />            
    <fieldset>
        <legend style="color: red;" align="center">
            ***** Procedimentos Anteriores realizados com este Paciente *****
        </legend> 
        <table border="1" style= "width: 100%">
            <thead style="background: black; color: white">
                <tr>
                    <th>Data/Horario</th>
                    <th>Serviço</th>                  
                    <th>Observações</th>                  
                </tr>
            </thead>
            <tbody>
                <c:forEach items="${requestScope.ListaConsultasAnteriores}" var="list">    
                    <tr>                
                        <th><f:formatDate value="${list.agenda.data}" pattern="dd/MM/yyyy HH:mm"/></th>
                        <c:forEach items="${requestScope.ListaServico}" var="sv"> 
                            <c:if test="${sv.idServico == list.servico.idServico}">
                                <th>${sv.descricao}</th>
                            </c:if>
                        </c:forEach>     
                        <th>${list.obs}</th>        
                    </tr>
                </c:forEach>
            </tbody>    
        </table>   
    </fieldset>
</div>

<script type="text/javascript">
    $(document).ready(function(){
        $("#cpServico").change( function(){
            //alert('a');
            $("#dvValor").load("BuscaConsultaAction?ac=ajax&id="+$("#cpServico").val());                
        });
    });
</script>